


tempfile datawithoutencodeerror

import delimited "rawdata/confidential/bagmap/zip_bag_bound_semicolon.csv",clear
duplicates drop
save `datawithoutencodeerror',replace


import delimited "intermediate/confidential/zip_bag_bound_center_soumcenters.txt",clear

keep  fid  near_dist 
merge 1:1 fid  using `datawithoutencodeerror',nogen

do "dofile/aux/rename_subdistrictnames_inthemap.do"

keep Bag_Mapmatchkey_namebase Bag_Mapmatchkey_numbase near_dist
duplicates drop
duplicates list Bag_Mapmatchkey_namebase
duplicates list Bag_Mapmatchkey_numbase
collapse (min) near_dist,by(Bag_Mapmatchkey_namebase Bag_Mapmatchkey_numbase)
rename near_dist d_centerdist
save  "intermediate/confidential/zip_bag_bound_center_soumcenters.dta", replace




